home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr10 / boxit010.zip / BOXIT.S < prev    next >
Text File  |  1993-06-24  |  9KB  |  225 lines

  1. /*
  2.   ┌╥─────────────────────────────────────────────────────────────────────╥┐
  3.   │║ Macro Title: BoxIt!                                                 ║│
  4.   │║ Version....: 0.10 for TSE 1.0 Pre-Release                           ║│
  5.   │║ Author.....: George J. De Bruin                                     ║│
  6.   │║ Address....: 1414 Shiloh Rd. Apt/Box 511                            ║│
  7.   │║              Plano, TX 75074                                        ║│
  8.   │║ Phone......: (214) 422-0266                                         ║│
  9.   │║ BBS Contact: Qedit support conferences on the following Mail Nets:  ║│
  10.   │║              RIME, Ilink, Intelec, Metrolink, FidoNet, EchoNet.     ║│
  11.   │║              Also available via the Ilink Editor's Conference, and  ║│
  12.   │║              directly on SemWare's Support BBS.                     ║│
  13.   │╟─────────────────────────────────────────────────────────────────────╢│
  14.   │║ This macro is hereby released as freeware.  Anyone may use          ║│
  15.   │║ or modify it in any way they see fit.  Future versions may carry    ║│
  16.   │║ more notices on distributing modified versions of BoxIt!            ║│
  17.   │╟─────────────────────────────────────────────────────────────────────╢│
  18.   │║                       R E L E A S E   N O T I C E                   ║│
  19.   │║                                                                     ║│
  20.   │║ This macro is officially released to SemWare for possible           ║│
  21.   │║ distribution in conjunction with The SemWare Editor, or an ancillary║│
  22.   │║ macro collection.                                                   ║│
  23.   │╟─────────────────────────────────────────────────────────────────────╢│
  24.   │║ Purpose:                                                            ║│
  25.   │║                                                                     ║│
  26.   │║ This is a simple macro that will draw a box around column blocked   ║│
  27.   │║ area using TSE's internal line drawing mode.  *ONLY* column blocks  ║│
  28.   │║ are supported at this time.                                         ║│
  29.   └╨─────────────────────────────────────────────────────────────────────╨┘
  30. */
  31.  
  32. constant MaxColumn = 1008               // Current Maximum in TSE
  33.  
  34. integer GlobalGap = 0,                  // Gap between block and box
  35.         TopGap = 0,
  36.         BottomGap = 0,
  37.         LeftGap = 0,
  38.         RightGap = 0,
  39.         BoxGlobal = TRUE,
  40.         BoxTop = TRUE,                  // Draw Top Line? (True or false)
  41.         BoxRight = TRUE,                // Draw Right Side? (T/f)
  42.         BoxLeft = TRUE,                 // Draw Left Side? (T/f)
  43.         BoxBottom = TRUE                // Draw Bottom Line? (T/f)
  44.  
  45. /* ─────────────────────────────────────────────────────────────────── */
  46. proc OptToggle( VAR integer opt)
  47.     opt = iif( opt, FALSE, TRUE )
  48.     return()
  49. end OptToggle
  50.  
  51. /* ─────────────────────────────────────────────────────────────────── */
  52. proc NumRead( VAR integer n)
  53.     string s[5] = str(n)
  54.  
  55.     n = iif(Read(s), val(s), n)
  56.     return()
  57. end NumRead
  58.  
  59. /* ─────────────────────────────────────────────────────────────────── */
  60. string proc StrOnOff(integer i)
  61.     return (iif(i, "On", "Off"))
  62. end StrOnOff
  63.  
  64. /* ─────────────────────────────────────────────────────────────────── */
  65. string proc StrBoxGlobal(integer i)
  66.     string ret[3]
  67.     if i < 3
  68.         ret = StrOnOff(i)
  69.     else
  70.         ret = "Inv"
  71.     endif
  72.     return( ret )
  73. end StrBoxGlobal
  74.  
  75. /* ─────────────────────────────────────────────────────────────────── */
  76. proc GotoRC(integer row, integer col)
  77.     GotoLine( row )
  78.     GotoColumn( col )
  79. end GotoRC
  80.  
  81. /* ─────────────────────────────────────────────────────────────────── */
  82. proc VLine(integer row1, integer col1, integer row2)
  83.  
  84.     integer direct = iif( row1 > row2, _UP_, _DOWN_ ) // Set Line Drawing
  85.                                                       // Direction
  86.     GotoRC( row1, col1 )                // Goto Starting Row & Column
  87.     while row2 <> CurrLine()            // Draw the line
  88.         LineDraw(direct)
  89.     endwhile
  90.     LineDraw( iif( direct == _UP_, _DOWN_, _UP_ ) ) // Make sure there is
  91.     LineDraw( iif( direct == _UP_, _DOWN_, _UP_ ) ) // a character in the
  92. end Vline
  93.  
  94. /* ─────────────────────────────────────────────────────────────────── */
  95. proc Hline(integer row1, integer col1, integer col2)
  96.  
  97.     integer direct = iif( col1 > col2, _LEFT_, _RIGHT_ ) // Set Line Drawing
  98.                                                          // Direction
  99.     GotoRC( row1, col1 )                // Goto Starting Row & Column
  100.     while col2 <> CurrCol()             // Draw the Line
  101.         LineDraw(direct)
  102.     endwhile
  103.     LineDraw( iif( direct == _LEFT_, _RIGHT_, _LEFT_ ) ) // Make sure there is
  104.     LineDraw( iif( direct == _LEFT_, _RIGHT_, _LEFT_ ) ) // a character in the
  105. end Hline
  106.  
  107. /* ─────────────────────────────────────────────────────────────────── */
  108. proc SetAllGaps()
  109.     NumRead(GlobalGap)                  // Get Global Gap Setting
  110.     TopGap = GlobalGap                  // Assign Global Gap to each side
  111.     BottomGap = GlobalGap
  112.     RightGap = GlobalGap
  113.     LeftGap = GlobalGap
  114.     pushkey(<enter>)                    // Update the menu
  115. end SetAllGaps
  116.  
  117. /* ─────────────────────────────────────────────────────────────────── */
  118. menu SideOnOff()
  119.     history
  120.     "&On",,CloseBefore
  121.     "O&ff",,CloseBefore
  122.     "&Invert",,CloseBefore
  123. end SideOnOff
  124.  
  125. /* ─────────────────────────────────────────────────────────────────── */
  126. proc SetAllSides()
  127.     SideOnOff()                         // Get Global Sides On / Off
  128.     BoxGlobal = MenuOption()            // Which Option was selected?
  129.     If BoxGlobal <> 3                   // If invert, don't do this
  130.         BoxGlobal = iif(BoxGlobal - 2, TRUE, FALSE) // On or Off?
  131.         BoxTop = BoxGlobal              // Assign value for each side
  132.         BoxBottom = BoxGlobal
  133.         BoxRight = BoxGlobal
  134.         BoxLeft = BoxGlobal
  135.     else
  136.         BoxTop = not BoxTop             // Invert current values
  137.         BoxBottom = not BoxBottom
  138.         BoxRight = not BoxRight
  139.         BoxLeft = not BoxLeft
  140.     endif
  141.     pushkey(<enter>)                    // Update the menu
  142. end SetAllSides
  143.  
  144. /* ─────────────────────────────────────────────────────────────────── */
  145. proc BoxIt()
  146.     integer ULC = 0,                    // Upper left column of block
  147.             ULR = 0,                    // Upper left row of block
  148.             LRC = 0,                    // Lower right column of block
  149.             LRR = 0,                    // Lower right row of block
  150.             InsLines = 0,
  151.             Insrt = Set(Insert, On)     // Turn Insert Mode on and Save
  152.                                         // Previous setting
  153.  
  154.     set(MsgLevel, _WARNINGS_ONLY_)      // Turn off display updates
  155.  
  156.     if isBlockInCurrFile() <> _COLUMN_  // Is there a column block in current
  157.         message("No Column Block In File.") // buffer? If not, then return.
  158.         return()
  159.     endif
  160.  
  161.     if isCursorInBlock() <> _COLUMN_    // Is the cursor in the block?
  162.         message("Cursor Not In Block.") // If not, then return.
  163.         return()
  164.     endif
  165.  
  166.     PushPosition()                      // Store Starting Location
  167.     GotoBlockBegin()
  168.  
  169.     ULC = CurrCol()
  170.     if (ULC - LeftGap <= 1) and (LeftGap >= 1) // If in first column, or left side
  171.                                         // is past the first column, return.
  172.         PopPosition()                   // Restore Starting position
  173.         message("Cannot Insert Box At or Before Beginning of Line.")
  174.         return()
  175.     endif
  176.  
  177.     ULR = CurrLine()
  178.     if (ULR == 1)                       // If first line of file,
  179.         PushPosition()                  // insert enough lines to permit
  180.         Begline()                       // drawing the box
  181.         while InsLines < TopGap + 1
  182.             SplitLine()
  183.             InsLines = InsLines + 1
  184.         endwhile
  185.         PopPosition()
  186.         ULR = CurrLine()
  187.     endif
  188.  
  189.     GotoBlockEnd()
  190.  
  191.     LRC = CurrCol()
  192.     if LRC == MaxColumn                 // If last column of buffer, return
  193.         PopPosition()                   // Restore Starting position
  194.         return()
  195.     endif
  196.  
  197.     LRR = CurrLine()
  198.  
  199.     if BoxTop                           // If BoxTop == TRUE, Draw Line
  200.         Hline( (ULR - (TopGap)), (ULC - (LeftGap)), (LRC + (RightGap)))
  201.     endif
  202.  
  203.     if BoxRight                         // If BoxRight == TRUE, Draw Line
  204.         VLine( (ULR - (TopGap)), (LRC + (RightGap)), (LRR + (BottomGap)))
  205.     endif
  206.  
  207.     if BoxBottom                        // If BoxBottom == TRUE, Draw Line
  208.         HLine( (LRR + (BottomGap)), (LRC + (RightGap)), (ULC - (LeftGap)))
  209.     endif
  210.  
  211.     if BoxLeft                          // If BoxLeft == TRUE, Draw Line
  212.         VLine( (LRR + (BottomGap)), (ULC - (LeftGap)), (ULR - (TopGap)))
  213.     endif
  214.  
  215.     PopPosition()                       // Restore Starting position
  216.     UnmarkBlock()                       // Get rid of block
  217.     Set(Insert, Insrt)                  // Restore Initial Insert Value
  218.     ScrollToRow(Query(WindowRows)/2)
  219.     Return()                            // Exit -- ALL DONE!
  220. end BoxIt
  221.  
  222. #include ["BoxIt.Hlp"]                  // Help Menus
  223. #include ["BoxIt.Mnu"]                  // BoxIt Menus
  224. #include ["BoxIt.Key"]                  // BoxIt Key Bindings
  225.